package com.qianhui.action;

import com.opensymphony.xwork2.ActionSupport;
import com.qianhui.dao.*;
import org.apache.struts2.ServletActionContext;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public abstract class BaseAction extends ActionSupport
{

    // 常用字符串
    public static final String GLOBAL_RESULT_HOME = "home";
    public static final String GLOBAL_RESULT_EXCEPTION = "exception";
    public static final String GLOBAL_RESULT_404 = "404";
    public static final String GLOBAL_RESULT_LOGIN = "login";
    public static final String GLOBAL_RESULT_GOODS_DOWN = "goods_down";
    public static final String GLOBAL_RESULT_ILLEGAL_REQUEST = "illegal_request";
    public static final String GLOBAL_RESULT_USER_404 = "user_404";

    // 常用DAO
    public AdvertisementDAO advertisementDAO;
    public ArticleDAO articleDAO;
    public BrowserHistoryDAO browserHistoryDAO;
    public BuyerAddressDAO buyerAddressDAO;
    public BuyerCollectionDAO buyerCollectionDAO;
    public BuyerCouponDAO buyerCouponDAO;
    public BuyerDAO buyerDAO;
    public BuyerMessageDAO buyerMessageDAO;
    public CartDAO cartDAO;
    public CommentDAO commentDAO;
    public CouponDAO couponDAO;
    public GoodsDAO goodsDAO;
    public GoodsHistoryDAO goodsHistoryDAO;
    public GoodsTypeDAO goodsTypeDAO;
    public ManagerDAO managerDAO;
    public OrderDAO orderDAO;
    public OrderGoodsDAO orderGoodsDAO;
    public OrderReturnDAO orderReturnDAO;
    public ShopDAO shopDAO;
    public GoodsCommissionDAO goodsCommissionDAO;
    public KefuDAO kefuDAO;
    public CommissionDayRecordDAO commissionDayRecordDAO;
    public CommissionMonthRecordDAO commissionMonthRecordDAO;
    public ManagerModuleDAO managerModuleDAO;
    public OrderDeclarationDAO orderDeclarationDAO;
    public ProvincePostageDAO provincePostageDAO;
    public PreCommissionDayRecordDAO preCommissionDayRecordDAO;
    public PreCommissionMonthRecordDAO preCommissionMonthRecordDAO;

    public String info;// 提示信息

    public BaseAction()
    {
        super();
        advertisementDAO = new AdvertisementDAO();
        articleDAO = new ArticleDAO();
        browserHistoryDAO = new BrowserHistoryDAO();
        buyerAddressDAO = new BuyerAddressDAO();
        buyerCollectionDAO = new BuyerCollectionDAO();
        buyerCouponDAO = new BuyerCouponDAO();
        buyerDAO = new BuyerDAO();
        buyerMessageDAO = new BuyerMessageDAO();
        cartDAO = new CartDAO();
        commentDAO = new CommentDAO();
        couponDAO = new CouponDAO();
        goodsDAO = new GoodsDAO();
        goodsHistoryDAO = new GoodsHistoryDAO();
        goodsTypeDAO = new GoodsTypeDAO();
        managerDAO = new ManagerDAO();
        orderDAO = new OrderDAO();
        orderGoodsDAO = new OrderGoodsDAO();
        orderReturnDAO = new OrderReturnDAO();
        shopDAO = new ShopDAO();
        goodsCommissionDAO = new GoodsCommissionDAO();
        kefuDAO = new KefuDAO();
        commissionDayRecordDAO = new CommissionDayRecordDAO();
        commissionMonthRecordDAO = new CommissionMonthRecordDAO();
        managerModuleDAO = new ManagerModuleDAO();
        orderDeclarationDAO = new OrderDeclarationDAO();
        provincePostageDAO = new ProvincePostageDAO();
        preCommissionDayRecordDAO = new PreCommissionDayRecordDAO();
        preCommissionMonthRecordDAO = new PreCommissionMonthRecordDAO();
    }

    public HttpServletRequest getRequest()
    {
        return ServletActionContext.getRequest();
    }

    public HttpServletResponse getResponse()
    {
        return ServletActionContext.getResponse();
    }

    public HttpSession getSession()
    {
        return getRequest().getSession();
    }

    public ServletContext getApplication()
    {
        return ServletActionContext.getServletContext();
    }

    public String getRealPath(String path)
    {
        return getApplication().getRealPath(path);
    }

    public String getInfo()
    {
        return info;
    }

    public void setInfo(String info)
    {
        this.info = info;
    }

}
